package mamikeji.liaowa.widget;

import android.content.Context;
import android.util.AttributeSet;
import android.webkit.WebView;

/**
 * Created by Administrator on 2017/6/30 0030.
 */
public class MyWebView extends WebView {
    private OnSizeChangedListener onSizeChangedListener;

    public MyWebView(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    public MyWebView(Context context) {
        super(context);
    }

    @Override
    protected void onSizeChanged(int w, int h, int ow, int oh) {
        super.onSizeChanged(w, h, ow, oh);
        if (onSizeChangedListener != null && h>0) {
            System.out.println("高度:"+h);
            onSizeChangedListener.sizeChanged(h);
        }
    }

    // 回调接口
    public interface OnSizeChangedListener {
        void sizeChanged(int h);
    }

    public void setOnSizeChanged(OnSizeChangedListener onSizeChangedListener) {
        this.onSizeChangedListener = onSizeChangedListener;
    }
}
